//
//  VBVisitorViewController.swift
//  VBo
//
//  Created by 赵世得 on 2016/10/23.
//  Copyright © 2016年 Zh. All rights reserved.
//

import UIKit

class VBVisitorViewController: UIViewController {
    
    var isLogin: Bool = VBUserAccountViewModel.sharedTools.isLogin
    var visitorVc: VBVisitorView?
    
    override func loadView() {
        if isLogin  {
            super.loadView()
        }else{
            setUpVisitorView()
        }
    }
    
    @objc private func loginClick(){
        let oauthVc = VBOauthViewController()
        let oauthNav = VBNavigationViewController(rootViewController: oauthVc)
        present(oauthNav, animated: true, completion: nil)
    }
    
    private func setUpVisitorView(){
        visitorVc = VBVisitorView()
        visitorVc?.closure = { [weak self] in
            self?.loginClick()
        }
        view = visitorVc
        setUpNav()
    }
    
    private func setUpNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(setImg: nil, title: "注册", target: self, action: #selector(loginClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(setImg: nil, title: "登录", target: self, action: #selector(loginClick))
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    lazy var tableView: UITableView = UITableView()
    
}
